package com.some;

import java.util.Arrays;

public class LargestNum {
    public String getLargestNum(int[] nums) {
        if (nums == null || nums.length == 0) {
            return "";
        }

        String[] strings = new String[nums.length];
        int a = 0;
        for (int num : nums) {
            strings[a++] = String.valueOf(num);
        }
        //System.arraycopy(nums,0,integers,0,nums.length);
        Arrays.sort(strings, (x, y) -> (y + x).compareTo(x + y));//注意

        StringBuilder stringBuilder = new StringBuilder();
        for (String s : strings) {
            stringBuilder.append(s);
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        int[] ints = {10,2};
        LargestNum largestNum = new LargestNum();
        System.out.println(largestNum.getLargestNum(ints));
    }
}
